#!/usr/bin/env python
# -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText

def send_mail(to_list,sub,content,sendtype='html'):
    mail_host="smtp.qq.com"
    mail_user="zhaoxiang"
    mail_user_full="695073552@qq.com"
    mail_pass="kfeefmbtqemybajb"
#     mail_host="mail.qyer.com"
#     mail_user="xiang.zhao@qyer.com"
#     mail_user_full="xiang.zhao@qyer.com"
#     mail_pass="zhaoxiang123"
    
    fromUser=mail_user+"<%s>"%mail_user_full
    
    msg = MIMEText(content,_subtype=sendtype,_charset='utf-8')
    msg['Subject'] = sub
    msg['From'] = fromUser;
    msg['To'] = to_list
    try:
        s = smtplib.SMTP()
        s.connect(mail_host)
        s.login(mail_user_full,mail_pass)
        s.sendmail(fromUser, to_list, msg.as_string())
        s.close()
        return True
    except Exception, e:
        print str(e)
        return False
    
if __name__ == '__main__':
    to_list=['xiang.zhao@qyer.com']
    sub='this is a warn emial'
    content='邮件报告&发送成功!'
    send_mail(','.join(set(to_list)),sub,content)
    